package com.hs.telepass.utils;

import android.os.Environment;
import com.hs.telepass.Constants;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class SDCardUtil {
	private static final String ROOT_PATH = "/Android/data/com.suntek.mway.xjmusic";
	private static final String CRASH_URI = "/crash";

	public static boolean isSDCardMounted() {
		return Environment.MEDIA_MOUNTED.equals(Environment
				.getExternalStorageState());
	}

	private static File getDirectory(String uri) {
		File directory = new File(Environment.getExternalStorageDirectory(),
				ROOT_PATH + uri);
		if (!directory.exists()) {
			directory.mkdirs();
		}
		return directory;
	}
	
	/** 获取崩溃日志文件的路径 */
	public static File getCrashDirectory() {
		return getDirectory(CRASH_URI);
	}

    /*public static String saveImgToSDCard(byte[] data) throws IOException {
        String now = DateUtil.today("yyyy_MM_dd_HHmmss");
        String fileNmae = now + ".jpg";
        File fileFolder = new File(Constants.IMG_DECTORY_PATH);
        if(!fileFolder.exists()){
            fileFolder.mkdirs();
        }
        File jpgFile = new File(Constants.IMG_DECTORY_PATH, fileNmae);
        FileOutputStream outputStream = new FileOutputStream(jpgFile);// 文件输出流
        outputStream.write(data); // 写入sd卡中
        outputStream.close(); // 关闭输出流
        return jpgFile.getPath();
    }*/
}
